package Module.WandaJob;

import Base.DataFactory;
import Base.TestBase;
import org.apache.commons.lang.StringUtils;

/**
 * Created by Alain on 2016/3/9.
 */
@SuppressWarnings("unused")
public class Job extends TestBase {
    private static TestBase TB = new TestBase();
    private static DataFactory DF = new DataFactory();
    private String requestURL=null, requestBody=null, response=null,
                sourceId    =   DF.getCellValue("WandaJob", "sourceId"),
                jobId       =   DF.getCellValue("WandaJob", "jobId");

    /*01.检查任务执行情况
    GET https://bim.wanda.cn/job/internal/query?sourceId={sourceId}&jobId={jobId}
    参数名     是否必选    类型      描述
    sourceId	否	       string	 文件ID
    jobId   	否	       Long	     任务ID*/
    public String checkJobStatus(){
        requestURL = "/job/internal/query?jobId="+jobId;

        if (StringUtils.isNotBlank(sourceId)){
            requestURL = TB.getURL(requestURL)+"sourceId="+sourceId;
        }

        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e) {

        }
        return  response;
    }

    /*02.接受客户端任务
    PUT https://bim.wanda.cn/job/internal/send
    参数名     是否必选    类型      描述
    */
    public String acceptClientTask(){
        requestURL = "/job/internal/send";

        try {
            response = TB.apiResponse(requestURL, "PUT", requestBody);
        } catch (Exception e) {

        }
        return response;
    }
}
